package comparator;

import java.util.Arrays;
import java.util.Comparator;

/**
 * Created by 5406160@qq.com on LiBoWen 李博闻.
 *
 * @ClassName : ArrayDemo
 * @Author : 54061
 * @Date: 2022/2/9 18:23
 */
public class ArrayDemo {
    public static void main(String[] args) {
        int[] arr = {3,1,4,2,5};
        System.out.println(Arrays.toString(arr));
        //默认排序
        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));

        Integer[] arr1 = {3,1,4,2,5};
        System.out.println(Arrays.toString(arr1));
        //指定排序规则
        Arrays.sort(arr1,new Comparator<Integer>(){

            @Override
            public int compare(Integer o1, Integer o2) {
                return o2 - o1;
            }
        });
        System.out.println(Arrays.toString(arr1));
    }
}
